import { createRouter, createWebHistory } from "vue-router";

const routes = [
  {
    path: "/",
    redirect: "/login",
  },
  {
    path: "/login",
    name: "loginPage",
    component: () => import("../view/login/login.vue"),
  },
  {
    path: "/home",
    name: "homePage",
    component: () => import("../view/home/home.vue"),
    redirect: "/home/index",
    children: [
      {
        path: "/home/index",
        name: "indexPage",
        component: () => import("../view/home/index.vue"),
        meta: {
          title: "首页",
        },
      },
      {
        path: "/home/bookedManage",
        name: "bookedManagePage",
        component: () => import("../view/bookedManage/bookedManage.vue"),
        meta: {
          title: "预约管理",
        },

        children: [
          {
            path: "/home/bookedManage/booking",
            name: "bookingPage",
            component: () => import("../view/bookedManage/booking.vue"),
            meta: {
              title: "预约挂号",
            },
          },
          {
            path: "/home/bookedManage/workingSchedule",
            name: "workingSchedulePage",
            component: () => import("../view/bookedManage/workingSchedule.vue"),
            meta: {
              title: "医生排班",
            },
          },
          {
            path: "/home/bookedManage/nucleicAcidAppointment",
            name: "nucleicAcidAppointment",
            component: () =>
              import("../view/bookedManage/nucleicAcidAppointment.vue"),
            meta: {
              title: "费用管理",
            },
          },

          {
            path: "/home/bookedManage/nucleicAcidAppointment",
            name: "nucleicAcidAppointment",
            component: () =>
              import("../view/bookedManage/nucleicAcidAppointment.vue"),
            meta: {
              title: "预约核酸检测",
            },
          },

          {
            //预约核酸检测 预约详情
            path: "/home/bookedManage/BookingDetails",
            name: "BookingDetails",
            component: () => import("../view/bookedManage/BookingDetails.vue"),
            meta: {
              title: "预约核酸检测",
            },
          },
          {
            path: "/home/bookedManage/appointmentExamination",
            name: "appointmentExamination",
            component: () =>
              import("../view/bookedManage/appointmentExamination.vue"),
            meta: {
              title: "预约体检",
            },
          },
          {
            path: "/home/bookedManage/appointmentDetails",
            name: "appointmentDetails",
            component: () =>
              import(
                "../components/appointmentExamination/appointmentDetails.vue"
              ),
            meta: {
              title: "预约详情",
            },
          },
          {
            path: "/home/bookedManage/reportDetails",
            name: "reportDetails",
            component: () =>
              import("../components/appointmentExamination/reportDetails.vue"),
            meta: {
              title: "报告详情",
            },
          },
        ],
      },
      {
        path: "/home/costdManage",
        name: "costManagePage",
        component: () => import("../view/costdManage/costdManage.vue"),
        meta: {
          title: "费用管理",
        },
        children: [
          {
            path: "/home/costdManage/RecordsConsumption",
            name: "RecordsConsumption",
            component: () =>
              import("../view/costdManage/RecordsConsumption.vue"),
            meta: {
              title: "门诊消费记录",
            },
          },
          {
            // 门诊消费记录 订单信息
            path: "/home/costdManage/torderInformation",
            name: "torderInformation",
            component: () =>
              import("../view/costdManage/torderInformation.vue"),
            meta: {
              title: "门诊消费记录",
            },
          },
          {
            path: "/home/costdManage/outpatients",
            name: "outpatientsPage",
            component: () => import("../view/costdManage/outpatients.vue"),
            meta: {
              title: "住院消费记录",
            },
          },
          {
            path: "/home/costdManage/costcontent",
            name: "costcontentPage",
            component: () => import("../view/costdManage/costcontent.vue"),
          },

          {
            path: "/home/oPCRecord",
            name: "OPCRecord",
            component: () => import("../view/costdManage/OPCRecord.vue"),
            meta: {
              title: "门诊充值记录",
            },
          },
          {
            path: "/home/particulars",
            name: "Particulars",
            component: () => import("../view/costdManage/Particulars.vue"),
            meta: {
              title: "充值详情",
            },
          },
          {
            path: "/home/pefund",
            name: "Pefund",
            component: () => import("../view/costdManage/Pefund.vue"),
            meta: {
              title: "退款记录",
            },
          },
          {
            path: "/home/prefundDetails",
            name: "PrefundDetails",
            component: () => import("../view/costdManage/PrefundDetails.vue"),
            meta: {
              title: "退款详情",
            },
          },
        ],
      },

      {
        path: "/home/hospitalInfoManage",
        name: "hospitalInfoManagePage",
        component: () =>
          import("../view/hospitalInfoManage/hospitalInfoManage.vue"),
        meta: {
          title: "医院信息",
        },
        children: [
          {
            path: "/home/hospitalInfoManage/medicalPlan",
            name: "medicalPlan",
            component: () =>
              import("../view/hospitalInfoManage/medicalPlan.vue"),
            meta: {
              title: "体检套餐",
            },
          },
          {
            path: "/home/hospitalInfoManage/medicalPlanAdd",
            name: "medicalPlanAdd",
            component: () =>
              import("../components/appointmentExamination/medicalPlanAdd.vue"),
            meta: {
              title: "新增体检套餐",
            },
          },
          {
            path: "/home/hospitalInfoManage/physicalExaminationProject",
            name: "physicalExaminationProject",
            component: () =>
              import(
                "../view/hospitalInfoManage/physicalExaminationProject.vue"
              ),
            meta: {
              title: "体检项目",
            },
          },
          {
            path: "/home/hospitalInfoManage/physicalExaminationProjectAdd",
            name: "physicalExaminationProjectAdd",
            component: () =>
              import(
                "../components/appointmentExamination/physicalExaminationProjectAdd.vue"
              ),
            meta: {
              title: "新增体检项目",
            },
          },
          {
            path: "/home/hospitalInfoManage/packageType",
            name: "packageType",
            component: () =>
              import("../view/hospitalInfoManage/packageType.vue"),
            meta: {
              title: "套餐类型",
            },
          },
          {
            path: "/home/hospitalInfoManage/packageTypeAdd",
            name: "packageTypeAdd",
            component: () =>
              import("../components/appointmentExamination/packageTypeAdd.vue"),
            meta: {
              title: "新增套餐类型",
            },
          },
        ],
      },
    ],
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});
// router.beforeEach((to, from, next) => {
//   console.log(to, from);
//   if (to.path == "/login") {
//     next();
//   } else {
//     if (sessionStorage.getItem("token")) {
//       next();
//     } else {
//       alert("登录已过期，请重新登录");
//       sessionStorage.removeItem("token");
//       sessionStorage.removeItem("userName");
//       sessionStorage.removeItem("userId");
//       next("/login");
//     }
//   }
//   next();
// });
export default router;
